uniform float progress;
attribute vec3 toPosition;
attribute vec3 color;
attribute vec3 toColor;
attribute float speed;
attribute float scale;
varying vec3 vColor;

void main() {

    vec3 disPos = toPosition - position;
    vec3 disColor = toColor - color;
    float _speed = progress / speed;

    vec3 pos;
    vec3 col;
    if(_speed <= 1.0) {
        pos = position + disPos * _speed;
        col = color + disColor * _speed;
    } else {
        pos = toPosition;
        col = toColor;
    }
    vColor = col;
    vec4 viewPosition = modelViewMatrix * vec4(pos, 1.0);
    gl_Position = projectionMatrix * viewPosition;
    gl_PointSize = scale;
    gl_PointSize *= 100. / -(modelViewMatrix * vec4(pos, 1.0)).z;
}